package com.codermn.demo8;


import java.io.*;

/**
 * @author jxau_scf
 * @date 2021/6/27 - 16:53
 */
public class TestFile2 {
    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        FileInputStream fis = new FileInputStream("C:\\Users\\lenovo\\Desktop\\config.txt");
        BufferedInputStream bis = new BufferedInputStream(fis);
        FileOutputStream fos = new FileOutputStream("C:\\Users\\lenovo\\Desktop\\copy.txt");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        int len = 0;
        while ((len = bis.read()) != -1){
            bos.write(len);
        }
        fos.close();
        fis.close();
        long end = System.currentTimeMillis();
        System.out.println("耗时："+(end - start) +"ms");
    }
//    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("C:\\Users\\lenovo\\Desktop\\copy.txt"));
//        oos.writeObject(new User("张三",20));
//        oos.close();
//        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\Users\\lenovo\\Desktop\\copy.txt"));
//        User user = (User)ois.readObject();
//        System.out.println("反序列化对象："+user);
//
//    }
//    public static void main(String[] args) throws IOException {
//        InputStreamReader isr = new InputStreamReader(new FileInputStream("utf-8格式的文本"), "UTF-8");
//        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("gbk格式文本"), "GBK");
//        int len = 0;
//        while ((len = isr.read()) != -1){
//            osw.write(len);
//        }
//        osw.close();
//        isr.close();
//    }

}
